<style>
.myTable {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 9pt;
	border:none;
}

.myTable td {
	padding: 5 5 5 5;
}

.main {
	border: #FFB988 solid;
	border-width: 0px 1px 1px 1px;
}

.blank {
	border: #FFB988 solid;
	border-width: 0px 0px 1px 0px;
}

.selected {
	background-color: #FFFFFF;
	border: #FFB988 solid;
	border-width: 1px 1px 0px 1px;
	cursor: pointer;
	cursor: hand;
}

.notselected {
	background-color: #FFB988;
	border: #FFB988 solid;
	border-width: 1px 1px 1px 1px;
	cursor: pointer;
	cursor: hand;
}

.bTable td.available{
	color: #425087;
}

.bTable td.notavailable{
	color: #DA800E;
}
</style>
<?

if($_SESSION['reg_domain_success']){
        if(!add_domain_mailbox_email($id,$_SESSION['domain4registration'],$_SESSION['mailbox_pass'])){
                $errorMsg = translate('error_creating_domain_mailbox');
        }
        unset($_SESSION['reg_domain_success'], $_SESSION['domain4registration'], $_SESSION['mailbox_pass']);
        //session_unregister_('domain4registration');
        //session_unregister_('mailbox_pass');
        $okMsg = translate('reg_domain_success');
//      $okMsg = 'Your domain has been registered/renewed successfully.';
}elseif($whois_changed=='yes'){
        if($_GET[errorMsg]!='{details_changed}'){
                $errorMsg = translate(substr($_GET[errorMsg],1,strlen($_GET[errorMsg])-2));
        }else{
                $okMsg = translate(substr($_GET[errorMsg],1,strlen($_GET[errorMsg])-2));
                unset($errorMsg);
        }
        $okMsg = translate('whois_changed');
//      $okMsg = 'Whois information updated successfully.';
}elseif($dns_changed=='yes'){
        if($_GET[errorMsg]!='{dns_changed}'){
                $errorMsg = translate(substr($_GET[errorMsg],1,strlen($_GET[errorMsg])-2));
        }else{
                $okMsg = translate(substr($_GET[errorMsg],1,strlen($_GET[errorMsg])-2));
                unset($errorMsg);
        }
}

$params[sid]=$sid;
$params[action]='del_domains';
$url_del="$baseURL/$webDIR/?".encode_params($params);

$params[action]='add_domain';
$url="$baseURL/$webDIR/?".encode_params($params);

$params[action]='details_domain';
$params[domain_action]='whois';
$details_url_whois="$baseURL/$webDIR/?".encode_params($params);
$params[domain_action]='dns';
$details_url_dns="$baseURL/$webDIR/?".encode_params($params);

$params[action]='renew_domain';
$renew_url="$baseURL/$webDIR/?".encode_params($params);

$domains=list_reseller_domains($id,'array');

$status_map = array('0'=>'Unapproved Registration','1'=>'Unapproved Renewal','2'=>'Unapproved Tranfer','3'=>'Unapproved Change','4'=>'Approved','5'=>'Rejected','6'=>'Suspended','7'=>'Transferring','8'=>'Transfer Fail','9'=>'Domain Expired',''=>'-');
$dom_search_res = search4domains($search_domain);
if(is_array($dom_search_res)){
	foreach($dom_search_res as $k=>$v){
		$dom_string[] = "'$k':'$v'";
	}
	$dom_string = implode(',',$dom_string);
}
?>

<script>
var current_domain = '';
var selected_tab = 'reg_dom_';
var selected_tab_div = 'reg_dom';
var dom_arr = {<?echo $dom_string;?>};
current_tooltip_div = '';

function choose_domain(dom){
	current_domain = dom;
//	document.getElementById(dom_arr[current_domain]).innerHTML.replace('the selected domain',current_domain);
	document.daForm.domain.value = current_domain;
	document.daForm.pass.value = '';
	document.daForm.repass.value = '';
	document.daForm.domain.readOnly = true;
	document.daForm.register_domain.value= 1;
	document.getElementById('info').style.display = 'block';
	document.getElementById('add_dom').style.display = 'block';

	current_tooltip_div = dom_arr[current_domain];

	if(document.getElementById(dom_arr[current_domain])){
		tooltip_action('block',dom_arr[current_domain]);
	}
}

function unselect_domain(){
		document.daForm.domain.readOnly = false;
		document.daForm.domain.value = '';
		document.daForm.pass.value = '';
		document.daForm.repass.value = '';
		document.getElementById('info').style.display = 'none';
		document.daForm.register_domain.value = 0;
}

function confirmSubmit(msg){
	var agree = confirm(msg);
	if (agree){
		return true;
	}else{
		return false;
	}
}

function fSubmit(form_url,param){
	document.daForm.action = form_url;
	document.daForm.add_param.value = param;
	document.daForm.submit();
}

function tooltip_action(display,id){
	if(document.getElementById(current_tooltip_div)){
		if(display == 'block'){
			document.getElementById(current_tooltip_div).style.display = 'none';
			document.getElementById(id).style.display = display;
		} else if(display == 'none'){
			document.getElementById(current_tooltip_div).style.display = 'block';
			if(id != current_tooltip_div){
				document.getElementById(id).style.display = display;
			}
		}
	}else {
		document.getElementById(id).style.display = display;
	}
}

function togle_tab(id){
	document.getElementById(selected_tab).className = 'notselected';
	selected_tab = id;
	document.getElementById(selected_tab).className = 'selected';

	document.getElementById(selected_tab_div).style.display = 'none';
	selected_tab_div = id.substring(0,(id.length-1));
	document.getElementById(selected_tab_div).style.display = 'block';

	if(selected_tab_div == 'add_dom' && document.daForm.register_domain.value == 1){
		unselect_domain();
	}

	if(selected_tab_div == 'reg_dom' && current_domain){
		choose_domain(current_domain);
	}

	if(selected_tab_div=='add_dom'){
		document.getElementById('submitata').value = 'Next >> Host My Domain';
		document.getElementById('mailbox_head').innerHTML = 'Step 1: Set up domain and e-mail box password';
		document.getElementById('reg_mailbox_text').style.display = 'none';
		document.getElementById('add_mailbox_text').style.display = 'block';
	}else if(selected_tab_div=='reg_dom'){
                document.getElementById('submitata').value = 'Next >> Select Payment Method';
                document.getElementById('mailbox_head').innerHTML = 'Step 2: Set up e-mail box password';
		document.getElementById('reg_mailbox_text').style.display = 'block';
		document.getElementById('add_mailbox_text').style.display = 'none';
	}
}

function showVAT(selectBoxVAT) {
	if (typeof(selectBoxVAT) == 'string') {
		var vatSelect = document.getElementById(selectBoxVAT);
		var optionSelect = document.getElementById(vatSelect.value);

		if (optionSelect.labela == 1) {
			showHide (true, 'vat_radio');
			showHide (true, 'vat_text');
			showVatNum (true);
                } else {
			showHide (false, 'vat_radio');
			showHide (false, 'vat_text');
			showVatNum (false);
		}
	}
}

function showVatNum(show) {
	showHide (show, 'vat_input');
	showHide (show, 'vat_input1');
}

function checkCompany(formObject) {
	if (typeof(formObject) == 'undefined') {
		return false;
	}

	if (formObject.company_name.value == '') {
		formObject.vat_registered[0].click();
	}
}

function showHide (show, objectId) {
	if (typeof(objectId) == 'string') {
		var Box = document.getElementById(objectId);

		switch (show) {
			case true:
				Box.style.display = 'block';
			break;
			case false:
				Box.style.display = 'none';
			break;
		}
	}
}
</script>

<table width="100%">
	<?
	if (isset($from_page)) {
		$paramsa[sid] = $sid;
		$paramsa[action] = "home";
		$urla = "$baseURL/$webDIR/?".encode_params($paramsa);
		echo "<tr><td align=right colspan=2><div style='padding: 4 4 4 4; text-align:right;'><a href='$urla'>&laquo; Back to Home</div></td></tr>";
	}
	?>
	<tr>
		<td colspan=2>
			<p>
				<font class="text">
					<b><?=translate('dom_manager');?></b><br><br><?=translate('dom_manager_desc');?>
				</font>
			</p>
		</td>
	</tr>
</table>
<?
if ($errorMsg) {
include_once('errorMsg.html');
}
if ($okMsg) {
include_once('okMsg.html');
}
?>
<br>
<table cellspacing=0 cellpadding=0 width=100% class=myTable>
	<tr>
		<td width=20 class='blank'>&nbsp</td>
		<td id='reg_dom_' class='selected' align=center onClick="togle_tab(this.id);"><b>Register/Transfer Domain Name</b></td>
		<td width=5 class='blank'>&nbsp</td>
		<td id='add_dom_' class='notselected' align=center onClick="togle_tab(this.id);"><b>Add Your Existing Domain Name</b></td>
		<td width=20 class='blank'>&nbsp</td>
	</tr>
	<tr>
		<td colspan=5 class='main'><br>
			<div id=reg_dom style='display:block;'>
				<table class='bTable' cellspacing=0 cellpadding=0 width=100%>
					<tr>
						<th colspan=2>Step 1: Domain look-up, Registration or Transfer</th>
					</tr>
					<tr>
						<td colspan=2>
							<form action='<?echo $url?>' method='POST' name='domain_search_form'>
								<input type=text name=search_domain maxlength=63 size=35 value='example.com' onClick="this.value='';"> <input type=submit value=Search><br>
								Available Domains : .com .net .org .info .biz .us
							</form>
						</td>
					</tr>
					<?
					if($domain_search_result and !is_array($domain_search_result)){
					?>
					<tr>
						<td valign=top>
							<? echo $domain_search_result; ?>
						</td>
						<td valign=top>
							<div id=available style='display:none;'>
								Register The Selected Domain
							</div>
							<div id=notavailable style='display:none;'>
								*Domain transfer means changing the domain registrar.*<br>Domain transfer fee: $8.00 USD<br>In order to transfer the selected domain successfully,<br>the following requirements must be fulfilled:<br><br> * the selected domain must not be expired;<br> * the selected domain must be older than 60 days;<br> * Make sure that the selected domain is not locked<br> at the current registrar;<br> * Make sure that you are able to check regularly<br> the e-mail specified in the Administrative contact<br> section of the selected domain WHOIS records;<br> * EPP authorization key is required to transfer<br> .org/.biz/.info/.us domain names.<br><br>If there are any problems, please contact the support<br>for assistance: <a href=mailto:support@resellerspanel.com>support@resellerspanel.com</a><br><br>Please, have in mind that all payments must comply<br>with our <a href='http://<? echo $baseDomain; ?>/terms/order_verification_policy.html' target=_blank>Order Verification Policy</a>.
							</div>
						</td>
					</tr>
					<?
					}
					?>
				</table>
			</div>
			<form action='<?echo $url?>' method='POST' name='daForm'>
			<div id=add_dom style='display:none;'>
				<table class='bTable' cellspacing=0 cellpadding=0 width=100%>
					<tr>
						<th colspan=2 id=mailbox_head>Step 2: Set up e-mail box password</th>
					</tr>
					<tr>
						<td colspan=2 style='padding-left:130px;'><div id='reg_mailbox_text' style='display: block; width: 300px;'>
						The domain, which you want
						to register/transfer, will directly open the
						<a href='<? echo "http://www.$domainname/?r=$userName"; ?>'>template</a> chosen by you.
						Please fill out the password fields of your main mailbox
						sales@yourdomain.com, which will be created as soon as your domain is added
						in our database.
						</div>
						<div id='add_mailbox_text' style='display: none; width: 300px;'>
						The domain, which you want to add, will open the
						<a href='<? echo "http://www.$domainname/?r=$userName"; ?>'>template</a> chosen by you.
						Please fill out the password fields of your main mailbox
						sales@yourdomain.com, which will be created as soon as your domain is added
						in our database.
						</div>
						</td>
					</tr>
					<tr>
						<td align=right><?=translate('enter_domain');?>:</td>
						<td><input type='text' name='domain'></td></tr>
					<tr>
						<td align=right><?=translate('enter_pass');?>:</td>
						<td><input type='password' name='pass'></td></tr>
					<tr>
						<td align=right><?=translate('reenter_pass');?>:</td>
						<td><input type='password' name='repass'></td>
					</tr>
					<tr>
						<td colspan=2>
							<div id='info' style="display:none;" width="100%" height="100%">
								<table border=1 width=100% cellspacing=0 style="border-left:solid 1px #FFC9AD;">
									<tr>
										<th colspan=3 align='center'>Step 3: Submit your Whois information</th>
									</tr>
									<?include('reviseDetails_.html')?>
									<tr>
										<td colspan=2 align='center'><a href="domain_terms.html" target="_blank"><?=translate('read_terms');?></a></td>
									</tr>
								</table>
							</div>
						</td>
					</tr>
					<tr>
						<td colspan=2><center><input type='submit' id='submitata' value='Next >> Select Payment Method'></center></td>
					</tr>
				</table>
			</div>
			<input type=hidden name=register_domain>
			<input type=hidden name=add_param>
			</form>
		</td>
	</tr>
</table>

<?
$tbl = "<br><table class=bTable cellspacing=0 cellspacing=0 width=100%>
	<tr>
		<th>Domain</th>
		<th>Status</th>
					<th>DNS</th>
					<th>Whois</th>
					<th>Expires on</th>
		<th>Delete</th>
	</tr>";

$domain_list = list_reseller_domains_($id);
foreach($domain_list as $dom=>$arr){
	$tbl .=	"
	<tr>
		<td style='padding-left:20px;'><a href='http://$dom' target=_blank>$dom</a></td>
		<td align=center>".($status_map[($arr[flags])])."</td>
		<td align=center>".(dns_check($dom) ? '<font color=green>OK</font>' : '<font color=red>NOT OK</font>').($arr[flags]==4 ? " <a href=# onClick=\"fSubmit('$details_url_dns','$dom');return false;\">[change]</a>" : "")."</td>
		<td align=center><a href=# onClick=\"fSubmit('$details_url_whois','$dom');return false;\">".($arr[flags]==4 ? '[change]' : '[view]')."</a></td>
		<td align=center>".(($arr[flags]==4 or $arr[flags]==9) ? "[".date('m/d/Y',strtotime($arr[expire_date]))."] <a href=# onClick=\"fSubmit('$renew_url','$dom');return false;\">[renew]</a>" : '-')."</td>
		<td align=center><a href=# onClick=\"if(confirmSubmit('Delete $dom ?')){fSubmit('$url_del','$dom');}return false;\">[delete]</a></td>
	</tr>
	";
}
if(!$domain_list){
	$tbl .=	'<tr><td align=center colspan=6>'.translate('no_domains').'</td></tr>';
}
$tbl .= "</table><input type=hidden name=add_param><br>";
echo $tbl;
?>

<script>
showVAT(document.daForm.country.value);
<?
if ($info['vat_registered'] == 1) {
	echo 'document.daForm.vat_registered[1].click();';
}
?>

if('<?echo $register_domain;?>' == 1){
	choose_domain('<?echo $domain;?>');
}

if('<?echo $register_domain;?>' == '' && '<?echo $errorMsg;?>' != ''){
        if('<?echo $domain_search_result[$domain];?>' == 'available'){
                document.domain_search_form.search_domain.value = '<?echo $domain;?>';
                document.domain_search_form.submit();
        }else if('<?echo $_POST[search_domain];?>' == ''){
                togle_tab('add_dom_');
                document.daForm.domain.value = '<?echo $domain;?>';
        }
}
</script>